home *** CD-ROM | disk | FTP | other *** search
- /*
- File: ShimSerialEntry.c
-
- Contains: PC Card Serial Driver.
-
- Version: xxx put version here xxx
-
- Copyright: © 1995-1998 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #include "PCCardSerialInternal.h"
-
-
-
-
-
-
-
-
-
-
- //////////////////////////////////////////////////////////////////////////////////////
- //
- // TheDriverDescription
- //
-
- enum
- {
- kWabbitDriverVersionMajor = 0x01,
- kWabbitDriverVersionMinor = 0x11,
- kWabbitDriverVersionStage = finalStage,
- kWabbitDriverVersionBuild = 0
- };
-
-
- DriverDescription TheDriverDescription = {
- kTheDescriptionSignature, /* OSType driverDescSignature */
- kInitialDriverDescriptor, /* DriverDescVersion driverDescVersion */
-
- {
- "\ppccard-serial", /* Name of UART hardware */
- kWabbitDriverVersionMajor, kWabbitDriverVersionMinor, /* NumVersion version */
- kWabbitDriverVersionStage, kWabbitDriverVersionBuild
- },
-
- {
- kDriverIsLoadedUponDiscovery | kDriverIsOpenedUponLoad, /* load & open when we’re found */
- "\p.Wabbit", /* Str31 driverName (OpenDriver param) */
- 0, 0, 0, 0, 0, 0, 0, 0, /* UInt32 driverDescReserved[8] */
- },
-
- {
- 1, /* ServiceCount nServices */
- {
- kServiceCategoryNdrvDriver, /* OSType serviceCategory */
- kNdrvTypeIsGeneric, /* OSType serviceType */
- 1, 0, 0, 0 /* NumVersion serviceVersion */
- }
- }
- };
-
-
-
-
-
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * DoDriverIO
- */
-
- OSStatus
- DoDriverIO( AddressSpaceID spaceID,
- IOCommandID ioCommandID,
- IOCommandContents ioCommandContents,
- IOCommandCode ioCommandCode,
- IOCommandKind ioCommandKind)
- {
- OSStatus status = noErr;
-
- #pragma unused (spaceID)
-
- /*
- * Note: Initialize, Open, KillIO, Close, and Finalize are either synchronous
- * or immediate. Read, Write, Control, and Status may be immediate,
- * synchronous, or asynchronous.
- *
- * Note 2: As described in the theory of operation the read and write
- * commands will be handled by the ".In" and ".Out" drivers that the ndrv
- * installed in the Unit Table.
- */
- switch (ioCommandCode)
- {
- // I/O Commands:
-
- case kReadCommand:
- status = DoRead(ioCommandID,(IOParam *) ioCommandContents.pb);
- break;
-
- case kWriteCommand:
- status = DoWrite(ioCommandID,(IOParam *) ioCommandContents.pb);
- break;
-
- case kKillIOCommand:
- status = DoKillIO(ioCommandID,(IOParam *) ioCommandContents.pb);
- break;
-
-
- // Control/Configuration Commands:
-
- case kControlCommand:
- status = DoControl((CntrlParam *) ioCommandContents.pb);
- break;
-
- case kStatusCommand:
- // DriverGestalt doesn't do anything so in the interest of getting this thing building
- // as part of Tomahawk I'll just comment it out for now because Excelsior's MasterInterfaces
- // don't include DriverGestalt.h (need to get this done later).
- // if (((CntrlParam *) ioCommandContents.pb)->csCode == kDriverGestaltCode)
- // status = DoDriverGestalt((CntrlParam *) ioCommandContents.pb);
- // else
- status = DoStatus((CntrlParam *) ioCommandContents.pb);
- break;
-
-
- // Initialize/Finalize Commands:
-
- case kInitializeCommand: /* Initialize */
- case kReplaceCommand: /* or replace an old driver */
- status = DoInitialization( ioCommandContents.initialInfo->refNum,
- &ioCommandContents.initialInfo->deviceEntry,
- (ioCommandCode == kReplaceCommand));
- break;
-
- case kFinalizeCommand: /* Finalize */
- case kSupersededCommand: /* or get ready to be replaced */
- status = DoFinalization( ioCommandContents.initialInfo->refNum,
- &ioCommandContents.initialInfo->deviceEntry,
- (ioCommandCode == kSupersededCommand));
- break;
-
- case kOpenCommand:
- status = DoOpen(ioCommandContents.pb);
- break;
-
- case kCloseCommand:
- status = DoClose(ioCommandContents.pb);
- break;
-
- default:
- status = paramErr;
- break;
- }
-
- /*
- * Force a valid result for immediate commands -- they must return a valid
- * status to the Driver Manager: returning kIOBusyStatus would be a bug.
- *
- * Non-immediate commands return a status from the lower-level routine. If the
- * status is kIOBusyStatus, we just return -- an asynchronous I/O completion
- * routine will eventually complete the request. If it's some other status, the
- * lower-level routine has completed a non-immediate task, so we call
- * IOCommandIsComplete and return its (presumably noErr) status.
- */
-
- if (ioCommandKind == kImmediateIOCommandKind)
- {
- /* Immediate commands return the operation status */
- }
-
- else if (status == 1)
- {
- /*
- * An asynchronous operation is in progress. The driver handler promises
- * to call IOCommandIsComplete when the operation concludes.
- */
- status = noErr;
- }
- else
- {
- /*
- * Normal command that completed synchronously. Dequeue the user's
- * parameter block.
- */
- status = IOCommandIsComplete(ioCommandID, status);
- }
-
- return status;
- }
-